home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / updateUIComponentCloseButton < prev    next >
Encoding:
Text File  |  2003-07-17  |  7.3 KB  |  226 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  08 Nov 2000
  22. //  Author:         bwk
  23. //
  24. //  Description:
  25. //      This script updates the size of the close buttons attached 
  26. //        to the main window components. This script also creates a
  27. //        popup menu parented to the component close boxes that
  28. //        contains a list of all the other main window components.
  29. //
  30. //        The updateUIComponentCloseButtons() procedure should only be
  31. //        called once at startup.
  32. //
  33. //        If a particular component changes size then it is up to that
  34. //        component to update it's corresponding close button.
  35. //
  36.  
  37. global proc updateUIComponentCloseButtons()
  38. //
  39. //    Description:
  40. //        Query the size of all the main window components and then set
  41. //        the corresponding close button so it is equal in height for 
  42. //        horizontal components or width for vertical components.
  43. //
  44. //        Also create a popup menu parented to the close button 
  45. //        containing all the components.
  46. //
  47. //        This procedure should only be called once during startup.
  48. //
  49. //
  50. {
  51.     //    The names of all the horizontal components.
  52.     //
  53.     string $horizontalComponentArray[] = {
  54.         "Status Line",
  55.         "Shelf",
  56.         "Time Slider",
  57.         "Range Slider",
  58.         "Command Line",
  59.         "Help Line"
  60.         };
  61.  
  62.     //    The names of all the vertical components.
  63.     //
  64.     string $verticalComponentArray[] = {
  65.         "Tool Box",
  66.         "Attribute Editor",
  67.         "Tool Settings",
  68.         "Channel Box / Layer Editor"
  69.         };
  70.  
  71.     int $buttonSize, $componentSize;
  72.  
  73.     //    For each horizontal component query it's height and then
  74.     //    apply that height to the corresponding close button.
  75.     //
  76.     for ($horizontalComponent in $horizontalComponentArray) {
  77.         $component = getUIComponent($horizontalComponent);
  78.         $closeButton = getUIComponentCloseButton($horizontalComponent);
  79.         $componentSize = `control -query -height $component`;
  80.         $buttonSize = `control -query -height $closeButton`;
  81.         if ($buttonSize < $componentSize) {
  82.             control -edit -height $componentSize $closeButton;
  83.         }
  84.         createUIComponentCloseButtonPopupMenu($closeButton);
  85.     }
  86.  
  87.     //    For each vertical component query it's width and then
  88.     //    apply that width to the corresponding close button.
  89.     //
  90.     for ($verticalComponent in $verticalComponentArray) {
  91.         $component = getUIComponent($verticalComponent);
  92.         $closeButton = getUIComponentCloseButton($verticalComponent);
  93.         $componentSize = `control -query -width $component`;
  94.         $buttonSize = `control -query -width $closeButton`;
  95.         if ($buttonSize < $componentSize) {
  96.             control -edit -width $componentSize $closeButton;
  97.         }
  98.         createUIComponentCloseButtonPopupMenu($closeButton);
  99.     }
  100. }
  101.  
  102. global proc createUIComponentCloseButtonPopupMenu(string $parent)
  103. //
  104. //    Description:
  105. //        Create a popup menu containing items for all the main window
  106. //        components.
  107. //
  108. //        Note that the menu items are not actually created at this
  109. //        time. They are created when the menu is posted by the user.
  110. //
  111. //    Arguments:
  112. //        $parent - The parent button for the popup menu.
  113. //
  114. {
  115.     string $popupMenu = `popupMenu -parent $parent -button 3`;
  116.  
  117.     popupMenu -edit
  118.         -postMenuCommand ("createUIComponentCloseButtonPopupMenuItems " + $popupMenu)
  119.         $popupMenu;
  120. }
  121.  
  122. global proc createUIComponentCloseButtonPopupMenuItems(string $popupMenu)
  123. //
  124. //    Description:
  125. //        Create the component menu items for the close button popup menu.
  126. //
  127. //    Arguments:
  128. //        $popupMenu - The parent popup menu for the menu items.
  129. //
  130. {
  131.     int $itemCount, $visible;
  132.  
  133.     //    Delete all the existing items.
  134.     //
  135.     $itemCount = `popupMenu -query -numberOfItems $popupMenu`;
  136.     if (0 < $itemCount) {
  137.         popupMenu -edit -deleteAllItems $popupMenu;
  138.     }
  139.  
  140.     createUIComponentMenuItems($popupMenu);
  141. }
  142.  
  143. global proc createUIComponentMenuItems(string $parentMenu)
  144. //
  145. //    Description:
  146. //        Create menu items for controlling the visibility of the main
  147. //        window UI elements.
  148. //
  149. //    Arguments:
  150. //        $parentMenu - Any parent menu.
  151. //
  152. {
  153.     setParent -menu $parentMenu;
  154.  
  155.     //    Get the visibility of each main window component and create
  156.     //    a menu item for it.
  157.  
  158.     $visible = isUIComponentVisible("Status Line");
  159.     menuItem -checkBox $visible -label "Status Line"
  160.         -annotation (getRunTimeCommandAnnotation("ToggleStatusLine"))
  161.         -command ("ToggleStatusLine");
  162.  
  163.     $visible = isUIComponentVisible("Shelf");
  164.     menuItem -checkBox $visible -label "Shelf"
  165.         -annotation (getRunTimeCommandAnnotation("ToggleShelf"))
  166.         -command ("ToggleShelf");
  167.  
  168.     $visible = isUIComponentVisible("Time Slider");
  169.     menuItem -checkBox $visible -label "Time Slider"
  170.         -annotation (getRunTimeCommandAnnotation("ToggleTimeSlider"))
  171.         -command ("ToggleTimeSlider");
  172.  
  173.     $visible = isUIComponentVisible("Range Slider");
  174.     menuItem -checkBox $visible -label "Range Slider"
  175.         -annotation (getRunTimeCommandAnnotation("ToggleRangeSlider"))
  176.         -command ("ToggleRangeSlider");
  177.  
  178.     $visible = isUIComponentVisible("Command Line");
  179.     menuItem -checkBox $visible -label "Command Line"
  180.         -annotation (getRunTimeCommandAnnotation("ToggleCommandLine"))
  181.         -command ("ToggleCommandLine");
  182.  
  183.     $visible = isUIComponentVisible("Help Line");
  184.     menuItem -checkBox $visible -label "Help Line"
  185.         -annotation (getRunTimeCommandAnnotation("ToggleHelpLine"))
  186.         -command ("ToggleHelpLine");
  187.  
  188.     menuItem -divider true;
  189.  
  190.     $visible = isUIComponentVisible("Tool Box");
  191.     menuItem -checkBox $visible -label "Toolbox"
  192.         -annotation (getRunTimeCommandAnnotation("ToggleToolbox"))
  193.         -command ("ToggleToolbox");
  194.  
  195.     menuItem -divider true;
  196.  
  197.     $visible = isUIComponentVisible("Attribute Editor");
  198.     menuItem -checkBox $visible -label "Attribute Editor"
  199.         -annotation (getRunTimeCommandAnnotation("ToggleAttributeEditor"))
  200.         -command ("ToggleAttributeEditor");
  201.  
  202.     $visible = isUIComponentVisible("Tool Settings");
  203.     menuItem -checkBox $visible -label "Tool Settings"
  204.         -annotation (getRunTimeCommandAnnotation("ToggleToolSettings"))
  205.         -command ("ToggleToolSettings");
  206.  
  207.     $visible = isUIComponentVisible("Channel Box / Layer Editor");
  208.     menuItem -checkBox $visible -label "Channel Box / Layer Editor"
  209.         -annotation (getRunTimeCommandAnnotation("ToggleChannelsLayers"))
  210.         -command ("ToggleChannelsLayers");
  211.  
  212.     menuItem -divider true;
  213.  
  214.     menuItem -label "Hide UI Elements"
  215.         -annotation (getRunTimeCommandAnnotation("HideUIElements"))
  216.         -command ("HideUIElements");
  217.  
  218.     menuItem -label "Show UI Elements"
  219.         -annotation (getRunTimeCommandAnnotation("ShowUIElements"))
  220.         -command ("ShowUIElements");
  221.  
  222.     menuItem -label "Restore UI Elements"
  223.         -annotation (getRunTimeCommandAnnotation("RestoreUIElements"))
  224.         -command ("RestoreUIElements");
  225. }
  226.